package com.qifan.energy.adapter;

import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.qifan.energy.R;
import com.qifan.energy.bean.result.RecommendRelationResult;
import com.qifan.energy.util.DateTimeUtils;

import java.util.List;

public class RecommendRelationAdapter extends BaseQuickAdapter<RecommendRelationResult.ChildListBean,BaseViewHolder> {

    public RecommendRelationAdapter(@Nullable List<RecommendRelationResult.ChildListBean> data) {
        super(R.layout.recommend_relation_item, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, RecommendRelationResult.ChildListBean item) {
        String dateStr = DateTimeUtils.getDateStr(item.getCreateTime(),null);
        helper.setText(R.id.title_tv,item.getNickname())
                .setText(R.id.add_date_tv, String.format("加入时间：%s",dateStr))
                .setText(R.id.accumulation_time_tv,String.format("累计时间(分钟)：%.02f",item.getExpendTimeCard()));
        TextView reachTv = helper.getView(R.id.reach_tv);
        if (item.getIsReached() == 0){
            reachTv.setText("未完成");
            reachTv.setBackgroundResource(R.drawable.shape_gray_r10);
        } else {
            reachTv.setText("已完成");
            reachTv.setBackgroundResource(R.drawable.shape_red_r10);
        }
    }
}
